function [position,isterminal,direction] = Ycrossing_atEarth(t,S)
GM_sun=1.327124400*10^(11);     %Sun
GM_earth=3.986004418*10^(5);    %Earth
GM_moon = 4.9048695*10^(3);     %Moon
%[km^3/s^2] Gravitational Parameters

% u_se = GM_earth / (GM_earth+GM_sun);
u_em = GM_moon / (GM_moon+GM_earth);
u_se = GM_earth / (GM_earth+GM_sun);
positionEarth = 1-u_se;
%[] Mu constant
%    se --> Sun-Earth system
%    em --> Earth-Moon system
position = S(1)-positionEarth; % The value that we want to be zero
isterminal = 1;  % Halt integration 
direction = 0;   % The zero can be approached from either direction